package com.edu.demo.mapper;

import com.edu.demo.entity.Report;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;

/**
 * <p>
 * 报告表 Mapper 接口
 * </p>
 *
 * @author jixuewei
 * @since 2023-01-12
 */
@Mapper
public interface ReportMapper extends BaseMapper<Report> {

    /**
     * 查询date这周的报告
     * @param projectId
     * @param date
     * @return
     */
    @Select("select * from report where project_id = #{projectId} and YEARWEEK(date_format(report_time,'%Y-%m-%d'),1) = YEARWEEK(#{date},7)")
    Report selectReportByWeekOfDate(@Param("projectId") Integer projectId, @Param("date")Date date);

    @Select("select count(*) from report where project_id = #{pid} and stu_id = #{stu}")
    int count(@Param("pid") int pid,@Param("stu") int stuId);

}
